package com.citywithincity.db.validate.mysql;

import com.citywithincity.db.DbValidateException;
import com.citywithincity.db.interfaces.IColumnDataValidate;
import com.citywithincity.utils.ValidateUtil;

public class NumberValidate implements IColumnDataValidate {

	@Override
	public Object validateData(Object data) throws DbValidateException {
		if(data instanceof Integer || data instanceof Long){
			return data;
		}
		if(data instanceof String){
			if(!ValidateUtil.isNumeric((String)data)){
				throw new DbValidateException("请输入数字");
			}
			return data;
		}
		throw new DbValidateException("不能转换为数字");
	}

}
